package com.browsesoft.htmlcomponent;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class HTMLFormPrintComponent extends HTMLFormComponent {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * 构造函数
	 * 
	 * @param parent
	 * @throws Exception
	 */
	public HTMLFormPrintComponent(HTMLBasicComponent parent) throws Exception {
		super(parent);
	}

	/**
	 * 设置打印
	 * 
	 * @throws Exception
	 */
	protected void updateElement() throws Exception {
		// Element print =
		// (Element)this.getPage().getDocument().getElementsByTagName(
		// "body").item(0);
		// print.setAttribute("onload",
		// "javascript:window.print();window.close()");

		// 调用父类的updateElement方法，让子组件更新
		super.updateElement();
	}

	protected void changeModel(HttpServletRequest request,
			HttpServletResponse response) {
		try {
			String componentId = request.getParameter("compid");
			HTMLBasicComponent component = HTMLBasicComponent.getComponentByID(
					request, componentId);
			this.model = component.getModel();
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
}
